<template>
	<view style="background-color: rgb(241, 241, 241);padding: 15px;">

		<view class="docter-item"  v-for="(item, index) in docterList"  @click="goTo(item.index)">
			<view class="docter-item-firstview">
				<image class="docter-item-img"
					:src="item.faceurl"></image>
				<view class="docter-item-des">{{item.docterName}}</view>
			</view>
			<view class="docter-item-time">8:30-18:00</view>
		</view>
		
	</view>
</template>

<script>
	import store from '@/store'
	import * as UserApi from '@/api/user'
	import * as ReservationApi from '@/api/reservation'
	import {
		checkLogin
	} from '@/core/app'
	
	export default {
		data() {
			return {
				docterList:[
					// {"docterName":"王医生 【副主任医师 10年】",
					// "index":1,
					// "faceurl":"http://127.0.0.1/uploads/10001/20231018/e37702ac8171c2b532ef98b5dec802fb.jpg",
					// "docterDetail":"123123123"},
					// {"docterName":"谢医生 【副主任医师 10年】】",
					// "index":2,
					// "faceurl":"http://127.0.0.1/uploads/10001/20231018/e37702ac8171c2b532ef98b5dec802fb.jpg",
					// "docterDetail":"56456456456"},
					// {"docterName":"赵医生 【副主任医师 10年】",
					// "index":3,
					// "faceurl":"http://127.0.0.1/uploads/10001/20231018/e37702ac8171c2b532ef98b5dec802fb.jpg",
					// "docterDetail":"789789789789"},
				]
			}
		},
		onShow(options) {
			this.onRefreshPage()
		},


		methods: {
			// 刷新页面
			onRefreshPage() {
			
				// 判断是否已登录
				this.isLogin = checkLogin()
				// 获取页面数据
				this.getPageData()
			},
			
			// 获取页面数据11
			getPageData() {
				const app = this
				app.isLoading = true
				// Promise.all([app.getUserInfo(),app.getMyReservationLists()])
				Promise.all([app.getMyDocterLists()])
					.then(() => app.isLoading = false)
			},
			
			goTo(docter_id) {
				this.$navTo('pages/reservation/docter_detail', {docid: docter_id })
			},
			//获取医生列表
			getMyDocterLists() {
				const app = this
				return new Promise((resolve, reject) => {
					// !app.isLogin ? resolve(null) : ReservationApi.docterList({}, {
					ReservationApi.docterList({}, {
							load: app.isFirstload
						})
						.then(result => {
							app.docterList = result.data.list
							resolve(app.docterList)
						})
						.catch(err => {
							if (err.result && err.result.status == 401) {
								app.isLogin = false
								resolve(null)
							} else {
								reject(err)
							}
						})
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.docter-item {
		height: 50px;
		display: flex;
		background-color: rgb(255, 255, 255);
		border-radius: 20px;
		padding-left: 10px;
		margin-bottom: 15px;
		align-items: center;
		justify-content: space-between;
	}

	.docter-item-firstview {
		display: flex;
		align-items: center;
	}

	.docter-item-img {
		margin-right: 10px;
		float: left;
		border-radius: 100px;
		width: 32px;
		height: 32px;
	}

	.docter-item-des {
		float: left;
		font-size: 13px;
		font-weight: bold;
		margin-right: 10px;
	}

	.docter-item-time {
		font-size: 11px;
		padding-right: 15px;
		color: rgb(155, 158, 170);
	}
</style>